package com.qc31.baselib.utils

import android.content.Context
import android.view.Gravity
import android.widget.Toast
import androidx.annotation.StringRes

fun Context.toast(msg: Any) {
    Toast.makeText(this, msg.toString(), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
}

fun Context.toast(@StringRes msgId: Int) {
    Toast.makeText(this, getString(msgId), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
}

fun Any.toast(context: Context) {
    Toast.makeText(context, toString(), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
}

fun Any.toastLong(context: Context) {
    Toast.makeText(context, toString(), Toast.LENGTH_LONG).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
}

fun Int.toast(context: Context) {
    Toast.makeText(context, context.getString(this), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
//    MToast.showShortToast(context, context.getString(this))

}

fun Context.showToast(msg: Any) {
    Toast.makeText(this, msg.toString(), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }

}

fun Context.showToast(@StringRes msgId: Int) {
    Toast.makeText(this, getString(msgId), Toast.LENGTH_SHORT).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }

}

fun Context.showLongToast(@StringRes msgId: Int) {
    Toast.makeText(this, getString(msgId), Toast.LENGTH_LONG).run {
        setGravity(Gravity.CENTER, 0, 0)
        show()
    }
}



